home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
3922
/
3922.xpi
/
chrome
/
content
/
overlay.js
next >
Wrap
Text File
|
2006-11-27
|
2KB
|
64 lines
var DictionaryLookup = {
onLoad: function()
{
this.initialized = true;
document.getElementById("contentAreaContextMenu").addEventListener(
"popupshowing",DictionaryLookup.onContextMenu,false);
},
onContextMenu: function()
{
var focusedWindow = document.commandDispatcher.focusedWindow;
var strSearch = focusedWindow.getSelection().toString().replace(/^\s*|\s*$/g,'');
var nLength = strSearch.length;
if( nLength == 0 || nLength > 40 )
{
// Nothing or too long text selected -> hide menu options
document.getElementById("dictLookupSeperator").hidden = true;
document.getElementById("dictLookupDictCtrl").hidden = true;
document.getElementById("dictLookupWikiCtrl").hidden = true;
}
else
{
var bundle = document.getElementById("dictlookupLocale");
// enable menu options
document.getElementById("dictLookupSeperator").hidden = false;
document.getElementById("dictLookupDictCtrl").hidden = false;
document.getElementById("dictLookupWikiCtrl").hidden = false;
// display selected text, too
document.getElementById("dictLookupDictCtrl").label =
bundle.getString("translate") + ": \"" + strSearch + "\"";
document.getElementById("dictLookupWikiCtrl").label =
bundle.getString("wikipediaLookup") + ": \"" + strSearch + "\"";
}
},
dictLookup: function()
{
// what a nice command:
var strSearch = document.commandDispatcher.focusedWindow.getSelection().toString().replace(/^\s*|\s*$/g,'');
var bundle = document.getElementById("dictlookupLocale");
var DICTIONARY_URL = bundle.getString("DICTIONARY_URL");
var strAddr = DICTIONARY_URL + encodeURIComponent(strSearch);
window.open( strAddr,
'querybox',
'status=no,resizable=yes,scrollbars=yes,toolbar=no,location=no,menubar=no,width=300,height=400');
},
wikiLookup: function()
{
var strSearch = document.commandDispatcher.focusedWindow.getSelection().toString().replace(/^\s*|\s*$/g,'');
var bundle = document.getElementById("dictlookupLocale");
var LEXICON_URL = bundle.getString("LEXICON_URL");
getBrowser().addTab(LEXICON_URL + encodeURIComponent(strSearch));
},
};
window.addEventListener("load", function(e) { DictionaryLookup.onLoad(e); }, false);